<?php include_once 'Pecahan/sessionLontong.php'; ?>

<?php
    include_once 'controller/login.php';
    include_once 'controller/photo.php';
    if(isset ($_POST['search_photo_button'])) {
        $photo = new photo();
        $result = $photo->showPhotoByKeyword($_POST['search_photo']);
    }
?>
<?php $judul = 'Cari Foto'; ?>
<?php include_once 'Pecahan/header.php'; ?>
        <table class="tabel">
            <tr>
                <th>
                    <div>
                        <form class="search" action="searchuser.php" method="post">
                            <label>User Name:</label>
                            <input type="text" name="search_user" id="search_user"/>
                            <input type="submit" value="Search User" id="search_user_button" name="search_user_button"/>
                        </form>
                    </div>
                </th>
                <th>
                    <div>
                        <form class="search" action="searchphoto.php" method="post">
                            <label>Photo:</label>
                            <input type="text" name="search_photo" id="search_photo"/>
                            <input type="submit" value="Search Photo" id="search_photo_button" name="search_photo_button"/>
                        </form>
                    </div>
                </th>
            </tr>
        </table>
        <div class="isipage">
            <div class="isipagestandar">
                <div>
                    
                </div>
                <div class="space">

                </div>
                <div>
                    <?php
                        include_once 'controller/follow.php';
                        $listFollow = new follow();
                        $iterate=0;
                        while($row = mysql_fetch_array($result)){
                            include_once 'controller/follow.php';
                            $fol = new follow();
                            if ($row['photo_prev'] == 'login_user'){
                                if ($name_logon == NULL){
                                    continue;
                                }
                            }else if ($row['photo_prev'] == 'owner'){
                                if ($name_logon != $row['user_name']){
                                    continue;
                                }
                            }else if ($row['photo_prev'] == 'follower_user'){
                                $follow = $fol->isFollowing($row['user_name'], $name_logon);
                                if ($name_logon == $row['user_name']){

                                }else if (!$follow){
                                    continue;
                                }
                            }
                    ?>
                    <div class="floatleft" id="photogallery">
                        <?php
                            $iterate++;
                            $urlProfile = "foto_zoom.php?name_viewed=" . $row['user_name'];
                        ?>
                        <a href="<?php echo $urlProfile ?>" >
                            <img id="<?php echo "foto_" . $iterate?>" name="<?php echo "foto_" . $iterate?>" src="<?php echo $row['url_photo'] ?>" alt="<?php echo "foto_" . $iterate?>" width="100" height="100" border="0"/>
                        </a>
                        <div>
                            <label><?php echo $row['key_word'] ?></label>
                        </div>
                        
                    </div>
                    <?php } ?>
                </div>
            </div>
        </div>
        <?php include_once 'Chat/chat.php';?>
<?php include_once 'Pecahan/footer.php'; ?>
